{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='koi_common_nav'}
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">基本信息</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form" name="form2" id="form2">
                <input type="hidden" name="m_id" value="{$item['m_id']}"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>


                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">第一锦鲤卡：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="first">
                                <option value="0" {if empty($item['first']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $lottery_koi  $val}s
                                <option value="{$val['l_id']}" {if $item['first'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}
                            </select>

                        </div>

                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">第二锦鲤卡：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="second">
                                <option value="0" {if empty($item['second']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $lottery_koi  $val}
                                <option value="{$val['l_id']}" {if $item['second'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}
                            </select>

                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">第三锦鲤卡：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="third">
                                <option value="0" {if empty($item['third']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $lottery_koi  $val}
                                <option value="{$val['l_id']}" {if $item['third'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}
                            </select>

                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">第四锦鲤卡：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="four">
                                <option value="0" {if empty($item['four']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $lottery_koi  $val}
                                <option value="{$val['l_id']}" {if $item['four'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}
                            </select>

                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">第五锦鲤卡：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="five">
                                <option value="0" {if empty($item['five']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $lottery_koi  $val}
                                <option value="{$val['l_id']}" {if $item['five'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}
                            </select>

                        </div>
                    </div>
                </div>



                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">合成锦鲤：</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <select class="form-control" name="compose">
                                <option value="0" {if empty($item['compose']) }selected="selected"{/if}>----------默认不显示----------</option>
                                {loop $compose_koi  $val}
                                <option value="{$val['l_id']}" {if $item['compose'] == $val['l_id'] }selected="selected"{/if}>{$val['title']}</option>
                                {/loop}

                            </select>

                        </div>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">状态</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <label class="radio-inline">
                            <input name="status" value="2" {if $item['status']==2 || !$item['status']} checked="checked"{/if} type="radio"> 关闭
                        </label>
                        <label class="radio-inline">
                            <input name="status" value="1" {if $item['status']==1} checked="checked"{/if} type="radio">启用
                        </label>
                        <span class="help-block">如：启用后将在前端展示</span>
                    </div>
                </div>


                <div class="form-group" id="sub_upload" >
                    <div class="col-sm-12">
                        <input name="submit" onclick="addOrEditLtItem()" id="btnConfirm" type="button" value="提交" class="btn btn-primary col-lg-2">
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(
        function (){
        }
    );
    function drop_confirm(msg, url){
        if(confirm(msg)){
            window.location = url;
        }
    }
    //新增\修改 提交数据
    function addOrEditLtItem() {

        let postUrl = "{php echo createWebUrl('koi',array('op'=>'method_update'));}";
        let success_redirect = "{php echo createWebUrl('koi',array('op'=>'method_list'));}";
        let formData = $("#form2").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let res = e.message;
                let code = res.code;
                let msg = res.msg;
                if (code!=200){
                    layer.msg(msg)
                }else{
                    layer.msg(msg);
                    window.location.href = success_redirect;
                }

            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
    // 修改、删除奖品
    function changeOrDelLttInfo(e) {
        let ltt_id = e.getAttribute("data-id");
        let type = e.getAttribute("data-type");
        let themeid = e.getAttribute("data-themeid");
        let redirectUrl = e.getAttribute("data-edit-url");
        let postUrl ="";
        if (type=='edit'){
            window.location.href = redirectUrl;
        }
        // if (type=='del'){
        //     postUrl = "{php echo createWebUrl('lt_delltitem');}";
        //     layer.msg('您确定删除该奖品吗？',{
        //         btn:['确定','取消'],
        //         yes:function (index) {
        //             $.ajax({
        //                 url:postUrl,
        //                 dataType:'json',
        //                 method:'post',
        //                 data: {ltt_id:ltt_id,themeid:themeid},
        //                 success:function (e) {
        //                     let res = e.message;
        //                     let code = res.code;
        //                     let msg = res.msg;
        //                     if (code!=200){
        //                         layer.msg(msg);
        //                     }else{
        //                         layer.msg(msg);
        //                         location.reload();
        //                     }
        //                 },
        //                 fail:function (err) {
        //                     console.log(err)
        //                 }
        //             });
        //         }
        //     });
        // }
    }
</script>
